import * as type from '../mutation-type'

const initState = {
  // 详情
  product: {
    sort_index: null,
    id: null,
    name: '',
    price: null,
    url: '',
    properties: {
      type: null,
      weight: null,
      shape: null,
      gender: null,
      size: null,
    },
    sub_products: [],
    guess_you_like_ids: [],
  },
  subProduct: {
    id: null,
    sku_name: '',
    name: '',
    stock: '',
    order_index: null,
    url: '',
    thumbnail: {
      large: null,
      dot: null,
    },
    status: 'down',
    statistics: {
      in_stock: null,
      stock_warning: null,
      try: null,
      production: null,
      sold: null,
      tried: null,
      in_cart: null,
      wasted: null,
      aftermarket: null,
    },
    description: [
      {
        type: 'simple',
        photo: null,
        text: null,
      }
    ],
  },
  description: {
    type: 'simple',
    photo: null,
    text: null,
  },

  // 列表
  products: [],

  // 搜索
  result: [],
}

const state = _.cloneDeep(initState)

const mutations = {
  // 列表
  [type.GET_PRODUCTS] (state, value) {
    state.products = value
  },

  // 详情
  [type.GET_PRODUCT] (state, value) {
    state.product = value
  },

  // 搜索
  [type.SEARCH_PRODUCT] (state, value) {
    state.result = value
  },

}

export default {
  state,
  mutations
}
